/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
  ListNode* reverseList(ListNode* head) {

    // 前驱结点
    ListNode *pre = nullptr; 
    // 当前结点
    ListNode *cur = head;

    while(cur){
      ListNode *temp = cur->next;
      cur->next = pre;
      pre = cur;
      cur = temp;
    }

    return pre;

  }
};